﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Models;
using BLL;

namespace CSMF.Management.Page_Mayor
{
    public partial class MayorLocation_Detail : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["admin"] != null)
                {
                    int id = Convert.ToInt32(Request.QueryString["videoID"]);
                    Mayor info = MayorManager.GetMayorByID(id);
                    lblTitle1.Text = info.Title;
                    lblTitle2.Text = info.Title;
                    lblTitle3.Text = info.Title;
                    lblTitle4.Text = info.Title;
                    lblTitle5.Text = info.Title;
                    MayorLocation lo1 = MayorLocationManager.GetMayorLocationByIDAndV(1, id);
                    txtLocation1.Text = lo1.Location;
                    MayorLocation lo2 = MayorLocationManager.GetMayorLocationByIDAndV(2, id);
                    txtLocation2.Text = lo2.Location;
                    MayorLocation lo3 = MayorLocationManager.GetMayorLocationByIDAndV(3, id);
                    txtLocation3.Text = lo3.Location;
                    MayorLocation lo4 = MayorLocationManager.GetMayorLocationByIDAndV(4, id);
                    txtLocation4.Text = lo4.Location;
                    MayorLocation lo5 = MayorLocationManager.GetMayorLocationByIDAndV(5, id);
                    txtLocation5.Text = lo5.Location;
                }
                else
                {
                    Response.Write("<script language='javascript'>parent.location.href='../login.aspx';</script>");
                }
            }
        }


        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(Request.QueryString["videoID"]);
            MayorLocation lo1 = MayorLocationManager.GetMayorLocationByIDAndV(1, id);
            lo1.Location = txtLocation1.Text.Trim();
            MayorLocationManager.ModifyMayorLocation(lo1);
            MayorLocation lo2 = MayorLocationManager.GetMayorLocationByIDAndV(2, id);
            lo2.Location = txtLocation2.Text.Trim();
            MayorLocationManager.ModifyMayorLocation(lo2);
            MayorLocation lo3 = MayorLocationManager.GetMayorLocationByIDAndV(3, id);
            lo3.Location = txtLocation3.Text.Trim();
            MayorLocationManager.ModifyMayorLocation(lo3);
            MayorLocation lo4 = MayorLocationManager.GetMayorLocationByIDAndV(4, id);
            lo4.Location = txtLocation4.Text.Trim();
            MayorLocationManager.ModifyMayorLocation(lo4);
            MayorLocation lo5 = MayorLocationManager.GetMayorLocationByIDAndV(5, id);
            lo5.Location = txtLocation5.Text.Trim();
            MayorLocationManager.ModifyMayorLocation(lo5);
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "aaa", "alert('修改市长带你游视频信息成功。');window.opener.location.replace('MayorInfo_List.aspx');window.close();", true);
        }
    }
}
